<template>
	<view class="content">
				<uv-parse :content="content"></uv-parse>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:""
			};
		},
        onLoad(opt) {
            
            if(opt.id){
                this.id = opt.id
                this.getDetail()
                
                
            }
        },
		methods: {
          
            async  getDetail(){
              const {code,data}  = await  this.$api.articleMain({id:Number(this.id)})
              
              if(code==1){
                  this.content = data.content
              }
            
            },
			//添加照片
			addImgBtn() {
				this.$refs.addCarImg.open();
			},
			coleAddImg(){
				this.$refs.addCarImg.close();
			},
			//合同按钮
			contractBtn() {
				this.$refs.dzContract.open();
			},
			//合同弹窗关闭
			contractClose() {
				this.$refs.dzContract.close();
			},
			//更多照片
			moreImg() {
				this.$refs.checkCar.open();
			},
			//验证车弹窗关闭
			carImgClose() {
				this.$refs.checkCar.close();
			},
            async getCartImg(){
                    const {data}  =   await  this.$api.cartImage({order_id:this.id})
                    
                    this.imgList = data.list
                    
            },
            uploadFile (type, directory) {
              let vm = this
              uni.chooseImage({
                count: 1, //最多可以选择的图片总数
                // sizeType: sizeType, // 可以指定是原图还是压缩图，默认二者都有
                // sourceType: sourceType, // 可以指定来源是相册还是相机，默认二者都有
                success: async (res) => {
                  let data = {
                    filePath: res.tempFilePaths[0],
                    formData: {
                      directory
                    },
                    header: {
                        // #ifdef MP
                        'Content-Type': 'application/x-www-form-urlencoded',
                        // #endif
                      'Token': uni.getStorageSync('logintoken')
                    }
                  }
                  vm.$api.uploadImg(data).then(res => {
                        vm.form.pay_image=res.fullurl
                  })
                },
              })
            },
            addCarImgdata(){
                    
                    if(!this.form.pay_image) return this.$utils.msg('请上传支付凭证')
                    uni.showLoading({
                        title:'加载中'
                    })
                    this.$api.addPayImage(this.form).then(res=>{
                        uni.hideLoading()
                        
                        if(res.code==1){
                            this.$utils.msg('添加成功')
                            setTimeout(()=>{
                                uni.reLaunch({
                                    url:'/pages/tabbar/myOrder'
                                })
                            },800)
                        }else{
                            this.$utils.msg(res.msg)
                        }
                    })
                    
            }
		}
	}
</script>

<style lang="scss" scoped>
	.content{
        padding: 24rpx;
    }
</style>